home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / ear / mui23dev.lha / MUI / Developer / Modula / txt / MuiMacros.def < prev    next >
Text File  |  1994-06-29  |  16KB  |  499 lines

  1. DEFINITION MODULE MuiMacros;
  2.  
  3. (*$ DEFINE Locale:=FALSE *)
  4. (*$ DEFINE MUIOBSOLETE:=FALSE *)
  5.  
  6. (****************************************************************************
  7. **
  8. **      MUI Macros 2.0
  9. **
  10. **      Converted to Modula by Christian "Kochtopf" Scholz
  11. **
  12. **      refer also to MuiMacros.mod if you want to know, how they are made.
  13. **
  14. **      $Id: MuiMacros.def,v 1.6 1994/06/27 22:06:41 Kochtopf Exp Kochtopf $
  15. **
  16. **      $Log: MuiMacros.def,v $
  17. # Revision 1.6  1994/06/27  22:06:41  Kochtopf
  18. # put some Macros in MUIObsolete-Parenthesis, because one should
  19. # now use mMakeObj.
  20. #
  21. # Revision 1.5  1994/02/15  21:14:05  Kochtopf
  22. # neue Macros fuer Pop* und Register definiert,
  23. # HCenter und VCenter neu
  24. # PopUp entfernt und durch PopButton ersetzt.
  25. # neue Label-Macros LLabel eingefuehrt (aus mui.h)
  26. #
  27. # Revision 1.4  1994/02/09  14:50:03  Kochtopf
  28. # Versionsnummer in 2.0 geaendert.
  29. #
  30. **
  31. ****************************************************************************
  32. ** Class Tree
  33. ****************************************************************************
  34. **
  35. ** rootclass               (BOOPSI's base class)                      
  36. ** +--Notify               (implements notification mechanism)        
  37. **    +--Family            (handles multiple children)                
  38. **    !  +--Menustrip      (describes a complete menu strip)          
  39. **    !  +--Menu           (describes a single menu)                  
  40. **    !  \--Menuitem       (describes a single menu item)             
  41. **    +--Application       (main class for all applications)          
  42. **    +--Window            (handles intuition window related topics)  
  43. **    +--Area              (base class for all GUI elements)          
  44. **       +--Rectangle      (creates (empty) rectangles)               
  45. **       +--Image          (creates images)                           
  46. **       +--Text           (creates some text)                        
  47. **       +--String         (creates a string gadget)                  
  48. **       +--Prop           (creates a proportional gadget)            
  49. **       +--Gauge          (creates a fule gauge)                     
  50. **       +--Scale          (creates a percentage scale)               
  51. **       +--Boopsi         (interface to BOOPSI gadgets)              
  52. **       +--Colorfield     (creates a field with changeable color)    
  53. **       +--List           (creates a line-oriented list)             
  54. **       !  +--Floattext   (special list with floating text)          
  55. **       !  +--Volumelist  (special list with volumes)                
  56. **       !  +--Scrmodelist (special list with screen modes)           
  57. **       !  \--Dirlist     (special list with files)                  
  58. **       +--Group          (groups other GUI elements)                
  59. **          +--Register    (handles page groups with titles)          
  60. **          +--Virtgroup   (handles virtual groups)                   
  61. **          +--Scrollgroup (handles virtual groups with scrollers)    
  62. **          +--Scrollbar   (creates a scrollbar)                      
  63. **          +--Listview    (creates a listview)                       
  64. **          +--Radio       (creates radio buttons)                    
  65. **          +--Cycle       (creates cycle gadgets)                    
  66. **          +--Slider      (creates slider gadgets)                   
  67. **          +--Coloradjust (creates some RGB sliders)                 
  68. **          +--Palette     (creates a complete palette gadget)        
  69. **          +--Colorpanel  (creates a panel of colors)                
  70. **          +--Popstring   (base class for popups)                    
  71. **             +--Popobject(popup a MUI object in a window)           
  72. **             \--Popasl   (popup an asl requester)
  73. **
  74. ***************************************************************************)
  75.  
  76. IMPORT  MD:MuiD;
  77. IMPORT  ML:MuiL;
  78. IMPORT  UD:UtilityD;
  79. FROM    UtilityD IMPORT HookPtr;
  80. FROM    SYSTEM IMPORT ADDRESS, ADR, TAG;
  81.  
  82. TYPE    APTR    = ADDRESS;      (* just for readability *)
  83.         StrPtr  = ADDRESS;
  84.  
  85.         ShortString = ARRAY[0..3] OF CHAR;  (* for MakeID *)
  86.  
  87.         (* Here some Types you have to use, IF you want to fill the
  88.            array, the ListDisplayHook gets as parameter and which the hook
  89.            has to fill *)
  90.  
  91.         STRING      = ARRAY[0..128] OF CHAR;
  92.         STRPTR      = POINTER TO STRING;
  93.         STRARR      = ARRAY[0..10] OF STRPTR; (* set 10 to the number of columns you have in your list *)
  94.         STRARRPTR   = POINTER TO STRARR;
  95.  
  96.         (* Use it the following way :
  97.  
  98.         Your Hookfunction :
  99.  
  100.         PROCEDURE dspfunc(hook : HookPtr; array : APTR; entry : APTR) : APTR;
  101.  
  102.             BEGIN
  103.                 CAST(STRARRPTR,array)^[0]:=ADR(first string);
  104.                 CAST(STRARRPTR,array)^[1]:=ADR(second string);
  105.                 ...
  106.                 RETURN 0;
  107.             END dspfunc;
  108.  
  109.         As you see, it is the same as string-arrays in C  *)
  110.  
  111.  
  112.         (* Here your PROCEDURE-Prototype for your hookfunction : *)
  113.  
  114.         HookDef     = PROCEDURE(HookPtr, APTR, APTR):APTR;
  115.  
  116. (*
  117. **  MUI - Object Generation
  118. **
  119. **  These Macros are equal to the C-Macros which can be found in mui.h
  120. **  But notice, that you have a different usage of these :
  121. **
  122. **  Instead of
  123. **
  124. **      app = ApplicationObject,
  125. **
  126. **              ...
  127. **
  128. **            End;
  129. **
  130. **  you now write :
  131. **
  132. **      app := ApplicationObject(TAG(buffer,    (* TAG from SYSTEM *)
  133. **
  134. **              ...
  135. **
  136. **             tagEnd));    (* tagEnd imported from UtilityD *)
  137. **
  138. **  Also you can't use :
  139. **
  140. **      app := ApplicationObject(TAG(buffer,
  141. **
  142. **              ...
  143. **  ====>            window:=WindowObject(TAG(buffer, ... , tagEnd)),
  144. **              ...
  145. **
  146. **             tagEnd));
  147. **
  148. **  instead of this, you have to define your Window-Object before the
  149. **  Application-Object and then use the pointer in the App-Definition :
  150. **
  151. **      window := WindowObject(TAG(buffer, ... , tagEnd)),
  152. **
  153. **      app := ApplicationObject(TAG(buffer,
  154. **
  155. **              ...
  156. **                   window,
  157. **              ...
  158. **
  159. **             tagEnd));
  160. **
  161. **  So you can't define a whole application with one command if you need
  162. **  the pointer of some objects later on (for a Notify, etc.)
  163. **
  164. *)
  165.  
  166. CONST   Child           = MD.maGroupChild;
  167.         SubWindow       = MD.maApplicationWindow;
  168.         WindowContents  = MD.maWindowRootObject;
  169.  
  170. PROCEDURE WindowObject(tags : UD.TagItemPtr) : APTR;
  171. PROCEDURE ImageObject(tags : UD.TagItemPtr) : APTR;
  172. PROCEDURE NotifyObject(tags : UD.TagItemPtr) : APTR;
  173. PROCEDURE ApplicationObject(tags : UD.TagItemPtr) : APTR;
  174. PROCEDURE TextObject(tags : UD.TagItemPtr) : APTR;
  175. PROCEDURE RectangleObject(tags : UD.TagItemPtr) : APTR;
  176. PROCEDURE ListObject(tags : UD.TagItemPtr) : APTR;
  177. PROCEDURE PropObject(tags : UD.TagItemPtr) : APTR;
  178. PROCEDURE StringObject(tags : UD.TagItemPtr) : APTR;
  179. PROCEDURE ScrollbarObject(tags : UD.TagItemPtr) : APTR;
  180. PROCEDURE ListviewObject(tags : UD.TagItemPtr) : APTR;
  181. PROCEDURE RadioObject(tags : UD.TagItemPtr) : APTR;
  182. PROCEDURE VolumelistObject(tags : UD.TagItemPtr) : APTR;
  183. PROCEDURE FloattextObject(tags : UD.TagItemPtr) : APTR;
  184. PROCEDURE DirlistObject(tags : UD.TagItemPtr) : APTR;
  185. PROCEDURE SliderObject(tags : UD.TagItemPtr) : APTR;
  186. PROCEDURE CycleObject(tags : UD.TagItemPtr) : APTR;
  187. PROCEDURE GaugeObject(tags : UD.TagItemPtr) : APTR;
  188. PROCEDURE ScaleObject(tags : UD.TagItemPtr) : APTR;
  189. PROCEDURE BoopsiObject(tags : UD.TagItemPtr) : APTR;
  190. PROCEDURE ColorfieldObject(tags : UD.TagItemPtr) : APTR;
  191. PROCEDURE ColoradjustObject(tags : UD.TagItemPtr) : APTR;
  192. PROCEDURE PaletteObject(tags : UD.TagItemPtr) : APTR;
  193. PROCEDURE GroupObject(tags : UD.TagItemPtr) : APTR;
  194. PROCEDURE VirtgroupObject(tags : UD.TagItemPtr) : APTR;
  195. PROCEDURE ScrollgroupObject(tags : UD.TagItemPtr) : APTR;
  196. PROCEDURE ScrmodelistObject(tags : UD.TagItemPtr) : APTR;
  197. PROCEDURE VGroup(tags : UD.TagItemPtr) : APTR;
  198. PROCEDURE HGroup(tags : UD.TagItemPtr) : APTR;
  199. PROCEDURE ColGroup(cols : LONGCARD; tags : UD.TagItemPtr) : APTR;
  200. PROCEDURE RowGroup(rows : LONGCARD; tags : UD.TagItemPtr) : APTR;
  201. PROCEDURE PageGroup(tags : UD.TagItemPtr) : APTR;
  202. PROCEDURE VGroupV(tags : UD.TagItemPtr) : APTR;
  203. PROCEDURE HGroupV(tags : UD.TagItemPtr) : APTR;
  204. PROCEDURE ColGroupV(cols : LONGCARD; tags : UD.TagItemPtr) : APTR;
  205. PROCEDURE RowGroupV(rows : LONGCARD; tags : UD.TagItemPtr) : APTR;
  206. PROCEDURE PageGroupV(tags : UD.TagItemPtr) : APTR;
  207. PROCEDURE PopString(tags : UD.TagItemPtr) : APTR;
  208. PROCEDURE PopObject(tags : UD.TagItemPtr) : APTR;
  209. PROCEDURE PopAsl(tags : UD.TagItemPtr) : APTR;
  210. PROCEDURE Register(tags : UD.TagItemPtr) : APTR;
  211.  
  212.  
  213. (*
  214. **  MakeID
  215. **  Generate an ID out of a 4-char-string.
  216. **  Use it the as WindowID ! (look in MuiTest for an example!)
  217. *)
  218.  
  219. PROCEDURE MakeID (name : ShortString): LONGINT;
  220.  
  221. (*
  222. **
  223. **  Hook Macros
  224. **
  225. **  Use it the following way :
  226. **      1. Write your Hook-Function :
  227. **          PROCEDURE hookfunc(hook:HookPtr; obj : APTR; args : APTR) : APTR
  228. **              BEGIN
  229. **              ...
  230. **              END hookfunc;
  231. **          Note, that your function needs not to specify registers, but
  232. **          your PROCEDURE must be looking like name(HookPtr, APTR, APTR)!!
  233. **
  234. **      2. Define in your VAR-section a pointer to a Hookrecord :
  235. **          VAR hook    : UtilitiesD.HookPtr;
  236. **
  237. **      3. fill it with MakeHook :
  238. **          MakeHook(hookfunc,hook);
  239. **
  240. **      4. Use it with MUI, as you like, e.g. :
  241. **          DoMethod(button,TAG(buffer,MD.mmCallHook,hook,arg1,arg2));
  242. **
  243. *)
  244.  
  245. PROCEDURE MakeHook(entry:HookDef; VAR hook : HookPtr);
  246.  
  247. (*
  248. **
  249. **  Spacing Macros
  250. **
  251. **  (not all from mui.h)
  252. **
  253. *)
  254.  
  255. PROCEDURE HVSpace() : APTR;
  256. PROCEDURE HSpace(x : LONGCARD) : APTR;
  257. PROCEDURE VSpace(x : LONGCARD) : APTR;
  258. PROCEDURE HCenter(obj : APTR) : APTR;
  259. PROCEDURE VCenter(obj : APTR) : APTR;
  260.  
  261. (*
  262. **
  263. **  Popup-Object
  264. **
  265. **
  266. *)
  267.  
  268. PROCEDURE PopButton(img : ARRAY OF CHAR) : APTR;
  269.  
  270.  
  271. (*$ IF MUIObsolete *)
  272.  
  273. (*
  274. **
  275. ** String-Object
  276. **
  277. ** Creates a simple String-Gadget
  278. **
  279. *)
  280.  
  281. (*$ IF Locale *)
  282. PROCEDURE String(contents : StrPtr; maxlen : LONGINT) : APTR;
  283. PROCEDURE KeyString(contents : StrPtr; maxlen : LONGINT; key : CHAR) : APTR;
  284. (*$ ELSE *)
  285. PROCEDURE String(contents : ARRAY OF CHAR; maxlen : LONGINT) : APTR;
  286. PROCEDURE KeyString(contents : ARRAY OF CHAR; maxlen : LONGINT; key : CHAR) : APTR;
  287. (*$ ENDIF *)
  288.  
  289. (*
  290. **
  291. ** Checkmark
  292. **
  293. ** creates a Checkmark Gadget
  294. **
  295. *)
  296.  
  297. PROCEDURE Checkmark(selected : BOOLEAN) : APTR;
  298. PROCEDURE KeyCheckmark(selected : BOOLEAN; key : CHAR) : APTR;
  299.  
  300. (*
  301. **
  302. ** Buttons
  303. **
  304. ** Here the same note : Use small letters for Keybuttons!
  305. **
  306. *)
  307.  
  308. (*$ IF Locale *)
  309. PROCEDURE Simplebutton(name : StrPtr) : APTR;
  310. PROCEDURE Keybutton(name : StrPtr; key : CHAR) : APTR;
  311. (*$ ELSE *)
  312. PROCEDURE Simplebutton(name : ARRAY OF CHAR) : APTR;
  313. PROCEDURE Keybutton(name : ARRAY OF CHAR; key : CHAR) : APTR;
  314. (*$ ENDIF *)
  315.  
  316. (*$ ELSE *) (* if not obsolete *)
  317.  
  318. (*$ IF Locale *)
  319. PROCEDURE Simplebutton(name : StrPtr) : APTR;
  320. (*$ ELSE *)
  321. PROCEDURE Simplebutton(name : ARRAY OF CHAR) : APTR;
  322. (*$ ENDIF *)
  323.  
  324. (*$ ENDIF *) (* MUIObsolete *)
  325.  
  326. (*$ IF MUIObsolete *)
  327.  
  328. (*
  329. **
  330. **  Radio Object
  331. **
  332. *)
  333.  
  334. (*$ IF Locale *)
  335. PROCEDURE Radio(name : StrPtr; array : APTR) : APTR;
  336. (*$ ELSE *)
  337. PROCEDURE Radio(name : ARRAY OF CHAR; array : APTR) : APTR;
  338. (*$ ENDIF *)
  339.  
  340. (*$ IF Locale *)
  341. PROCEDURE KeyRadio(name : StrPtr; array : APTR; key : CHAR) : APTR;
  342. (*$ ELSE *)
  343. PROCEDURE KeyRadio(name : ARRAY OF CHAR; array : APTR; key : CHAR) : APTR;
  344. (*$ ENDIF *)
  345.  
  346.  
  347. (*
  348. **
  349. **  Cycle-Objects
  350. **
  351. *)
  352.  
  353. PROCEDURE Cycle(array : APTR) : APTR;
  354. PROCEDURE KeyCycle(array : APTR; key : CHAR) : APTR;
  355.  
  356. (*
  357. **
  358. **  Slider-Objects
  359. **
  360. *)
  361.  
  362. PROCEDURE Slider(min, max, level : LONGINT; horiz : BOOLEAN) : APTR;
  363. PROCEDURE KeySlider(min, max, level : LONGINT; horiz : BOOLEAN; key : CHAR) : APTR;
  364.  
  365. (*$ ENDIF *) (* MUIObsolete *)
  366.  
  367.  
  368.  
  369. (*
  370. **
  371. ** Label Objects
  372. **
  373. ** The same as in mui.h
  374. **
  375. ** Label()  : create a Label for Objects without a frame
  376. ** Label1() : create a label for Objects with a standard frame (Checkmarks...)
  377. ** Label2() : create a label for Objects with double high frame (String Gadgets...)
  378. **
  379. *)
  380.  
  381. (*$ IF Locale *)
  382. PROCEDURE Label(label : StrPtr) : APTR;
  383. PROCEDURE Label1(label : StrPtr) : APTR;
  384. PROCEDURE Label2(label : StrPtr) : APTR;
  385. PROCEDURE LLabel(label : StrPtr) : APTR;
  386. PROCEDURE LLabel1(label : StrPtr) : APTR;
  387. PROCEDURE LLabel2(label : StrPtr) : APTR;
  388. PROCEDURE KeyLabel(label : StrPtr; HiChar : CHAR) : APTR;
  389. PROCEDURE KeyLabel1(label : StrPtr; HiChar : CHAR) : APTR;
  390. PROCEDURE KeyLabel2(label : StrPtr; HiChar : CHAR) : APTR;
  391. PROCEDURE KeyLLabel(label : StrPtr; HiChar : CHAR) : APTR;
  392. PROCEDURE KeyLLabel1(label : StrPtr; HiChar : CHAR) : APTR;
  393. PROCEDURE KeyLLabel2(label : StrPtr; HiChar : CHAR) : APTR;
  394. (*$ ELSE *)
  395. PROCEDURE Label(label : ARRAY OF CHAR) : APTR;
  396. PROCEDURE Label1(label : ARRAY OF CHAR) : APTR;
  397. PROCEDURE Label2(label : ARRAY OF CHAR) : APTR;
  398. PROCEDURE LLabel(label : ARRAY OF CHAR) : APTR;
  399. PROCEDURE LLabel1(label : ARRAY OF CHAR) : APTR;
  400. PROCEDURE LLabel2(label : ARRAY OF CHAR) : APTR;
  401. PROCEDURE KeyLabel(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  402. PROCEDURE KeyLabel1(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  403. PROCEDURE KeyLabel2(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  404. PROCEDURE KeyLLabel(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  405. PROCEDURE KeyLLabel1(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  406. PROCEDURE KeyLLabel2(label : ARRAY OF CHAR; HiChar : CHAR) : APTR;
  407. (*$ ENDIF *)
  408.  
  409. (*
  410. **
  411. ** Controlling Objects
  412. **
  413. ** Again the same as in mui.h :
  414. **
  415. ** set : set an attribute of an object
  416. ** get : get an attribute of an object
  417. **       didn't work in previous releases :-( (but now!! :-)
  418. **
  419. *)
  420.  
  421. PROCEDURE get(obj : APTR; attr : LONGCARD; store : ADDRESS);
  422. PROCEDURE set(obj : APTR; attr : LONGCARD; value : LONGINT);
  423. PROCEDURE setmutex(obj : APTR; n : LONGINT);
  424. PROCEDURE setcycle(obj : APTR; n : LONGINT);
  425. (*$ IF Locale *)
  426. PROCEDURE setstring(obj : APTR; s : StrPtr);
  427. (*$ ELSE *)
  428. PROCEDURE setstring(obj : APTR; s : ARRAY OF CHAR);
  429. (*$ ENDIF *)
  430. PROCEDURE setcheckmark(obj : APTR; b : BOOLEAN);
  431. PROCEDURE setslider(obj : APTR; l : LONGINT);
  432.  
  433. (*
  434. ** Now some macros which are not part of mui.h (in other words : my own ;-)
  435. **
  436. ** First : NoteClose (app,obj,ID)
  437. **         ----------------------
  438. **         This macro sets up a notification on the close-gadget of a window.
  439. **         if it gets pressed, the app-obj gets back an ID
  440. **         app : the application-object, which will receive the ID
  441. **         obj : the window-object
  442. **         ID  : the ID, which will be send to the app-obj, when the user
  443. **               presses the close-gadget of the window-object specified in
  444. **               obj.
  445. *)
  446.  
  447. PROCEDURE NoteClose(app : APTR;
  448.                     obj : APTR;
  449.                     ID  : LONGINT);
  450.  
  451. (*
  452. **  Notebutton (app,obj,ID)
  453. **  -----------------------
  454. **  Sets up a notification on a button. If it gets pressed, the app-obj
  455. **  receives an ID.
  456. **  app : the app-obj, which will receive the ID.
  457. **  obj : the pointer to the Button-Object (created by Keybutton, etc.)
  458. **  ID  : The ID, which will be send to the app-obj.
  459. **
  460. *)
  461.  
  462. PROCEDURE NoteButton(app : APTR;
  463.                      obj : APTR;
  464.                      ID  : LONGINT);
  465.  
  466. (*
  467. ** RemMember (obj,member)
  468. ** ----------------------
  469. ** The following macro deletes a member from an object
  470. **
  471. ** obj      : The object which holds the child to remove
  472. ** member   : The child which shall be removed
  473. ** ATTENTION: You have to dispose the removed child-objects yourself!
  474. **
  475. *)
  476.  
  477. PROCEDURE RemMember(obj : APTR; member : APTR);
  478.  
  479. (*
  480. ** AddMember (obj,member)
  481. ** ----------------------
  482. ** This macro will add a new child to an group-  or application-object
  483. **
  484. ** obj      : The group or application to which the new object will be added
  485. ** member   : The new child-object which shall be added to obj.
  486. **
  487. *)
  488.  
  489. PROCEDURE AddMember(obj : APTR; member : APTR);
  490.  
  491. END MuiMacros.
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.